<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>循环输出金字塔</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
    </style>

    <script>
        window.onload = function () {
            var str = document.body.innerHTML
            for (var i = 0; i < 100; i+=2) {
                str += "<hr style='width: " + (i) + "%'>";
            }
            document.write(str);
        }
    </script>
</head>
<body>
<br>
<center>
    <h1>循环输出金子塔</h1>
</center>
<br>
<hr>
</body>
</html>